<?php

use backend\widgets\Bar;
use backend\grid\CheckboxColumn;
use backend\grid\ActionColumn;
use backend\grid\GridView;
use yii\widgets\Pjax;
use common\libs\Constants;
use yii\bootstrap\Html;
use backend\models\Complaints;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\ComplaintsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title                   = '举报内容';
$this->params['breadcrumbs'][] = '举报内容';
?>
<div class="row">
    <div class="col-sm-12">
        <div class="ibox">
            <?= $this->render('/widgets/_ibox-title') ?>
            <div class="ibox-content">
                <?= Bar::widget() ?>
                <!--                --><? //= $this->render('_search', ['model' => $searchModel]); ?>
                <?php Pjax::begin(); ?>
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel'  => $searchModel,
                    'columns'      => [
                        ['class' => CheckboxColumn::className()],

                        'id',
                        [
                            'attribute' => 'uid',
                            'label'     => "用户名",
                            'value'     => function ($model) {
                                return $model->u->username;
                            }

                        ],
//                        'type',
                        'contact_name',
                        'contact_phone',
                        'content',
                        [
                            'attribute' => 'status',
                            'filter'    => Constants::getComplaintsStatus(),
                            'value'     => function ($model) {
                                /**
                                 * @var \backend\models\Complaints $model
                                 */

//                                return Constants::getForbiddenStatus($model->forbidden);

                                return Html::a(Constants::getComplaintsStatus($model->status),
                                    ['update', 'id' => $model['id']], [
                                        'class'        => 'btn btn-xs btn-rounded ' . ($model->status == Complaints::STATUS_DEAL ? 'btn-info' : 'btn-danger'),
                                        'data-confirm' => $model->status != Complaints::STATUS_WAIT ? '确定此内容已处理？' : '确定修改为未处理？',
                                        'data-method'  => 'post',
                                        'data-pjax'    => '0',
                                        'data-params'  => [
                                            $model->formName() . '[status]' => $model->status != Complaints::STATUS_WAIT ? Complaints::STATUS_WAIT : Complaints::STATUS_DEAL
                                        ]
                                    ]);
                            },
                            'format'    => 'raw'
                        ],
                        'created_at:datetime',
                        // 'updated_at',

                        ['class' => ActionColumn::className(),],
                    ],
                ]); ?>
                <?php Pjax::end(); ?>
            </div>
        </div>
    </div>
</div>
